package com.octopus.yangj.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import com.octopus.yangj.customized.service.CustomizedEventService;
import com.octopus.yangj.generated.service.ClientService;
import com.octopus.yangj.generated.service.EmployeeRoleService;
import com.octopus.yangj.generated.service.EmployeeService;
import com.octopus.yangj.generated.service.EventCategoryService;
import com.octopus.yangj.generated.service.EventExecuteService;
import com.octopus.yangj.generated.service.ExecuteUnitService;
import com.octopus.yangj.generated.service.KnowledgeCategoryService;
import com.octopus.yangj.generated.service.KnowledgeService;
import com.octopus.yangj.generated.service.RolePermissionService;

@Component
public class ServiceFactory implements ApplicationContextAware {
	
	private static ApplicationContext applicationContext;  

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		ServiceFactory.applicationContext = applicationContext; 
	}
	
	public static ApplicationContext getApplicationContext() {  
        return applicationContext;  
    }  
	
	public static Object getBean(String name) throws BeansException {  
        return applicationContext.getBean(name);  
    }
	
	public static CustomizedEventService getEventService(){
		return (CustomizedEventService)getBean("eventService");
	}
	
	public static EventCategoryService getEventCategoryService(){
		return (EventCategoryService)getBean("eventCategoryService");
	}
	
	public static EventExecuteService getEventExecuteService(){
		return (EventExecuteService)getBean("eventExecuteService");
	}
	
	public static ExecuteUnitService getExecuteUnitService(){
		return (ExecuteUnitService)getBean("executeUnitService");
	}
	
	public static KnowledgeService getKnowledgeService(){
		return (KnowledgeService)getBean("knowledgeService");
	}
	
	public static KnowledgeCategoryService getKnowledgeCategoryService(){
		return (KnowledgeCategoryService)getBean("knowledgeCategoryService");
	}
	
	public static ClientService getClientService(){
		return (ClientService)getBean("clientService");
	}
	
	public static EmployeeRoleService getRoleService(){
		return (EmployeeRoleService)getBean("employeeRoleService");
	}
	
	public static EmployeeService getUserService(){
		return (EmployeeService)getBean("employeeService");
	}
	
	public static RolePermissionService getPermissionService(){
		return (RolePermissionService)getBean("rolePermissionService");
	}

}
